﻿using MiniExcelLibs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp10
{
    internal class TestCar2
    {

        public static void Tets()
        {
            List<QuestionOutData> questionOutDatas = new List<QuestionOutData>();
            string folderPath = @"C:\Users\humengjian\Desktop\新建文件夹\合并3";

            string[] files = Directory.GetFiles(folderPath);
            files = files.OrderBy(f => System.IO.Path.GetFileName(f)).ToArray();
            // 遍历并输出每个文件的路径
            foreach (string file in files)
            {
                string fileName = Path.GetFileNameWithoutExtension(file);

                using (Stream stream = File.OpenRead(file))
                {

                    var questionInputs = stream.Query<QuestionOutData>().ToList();
                    if (questionInputs == null || questionInputs.Count == 0)
                    {
                        return;
                    }
                    questionOutDatas.AddRange(questionInputs);
                }
            }
            using (var strem = File.Create($"outEnd3.xlsx"))
            {
                strem.SaveAs(questionOutDatas);
            }
        }
    }
}
